package com.xuecheng.search.controller;

import com.xuecheng.api.search.CoursePubSearchApi;
import com.xuecheng.api.search.dto.CoursePubIndexDTO;
import com.xuecheng.api.search.qo.QueryCoursePubModel;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.common.domain.response.RestResponse;
import com.xuecheng.search.service.CoursePubSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created on 2021/04/12/16:19 周一
 *
 * @author Lantin
 */
@RestController
public class ContentSearchController implements CoursePubSearchApi {

    @Autowired
    private CoursePubSearchService coursePubSearchService;


    @PostMapping("course_index")
    public PageVO<CoursePubIndexDTO> queryCoursePub(PageRequestParams params,
                                                    @RequestBody QueryCoursePubModel model) {

        return coursePubSearchService.queryCoursePubIndexWithCondition(params, model);
    }

    @GetMapping("course_index/{coursePubId}")
    public CoursePubIndexDTO queryCoursePubById(@PathVariable Long coursePubId) {

        return coursePubSearchService.queryCoursePubById(coursePubId);

    }

    @GetMapping("l/course_index/{coursePubId}")
    public RestResponse<CoursePubIndexDTO> getCoursePubById(@PathVariable Long coursePubId) {



        return coursePubSearchService.getCoursePubById(coursePubId);
    }
}
